﻿@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link href="~/css/shop.css" type="text/css" rel="stylesheet" />
    <link href="~/css/Sellerber.css" type="text/css" rel="stylesheet" />
    <link href="~/css/bkg_ui.css" type="text/css" rel="stylesheet" />
    <link href="~/font/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="~/layui-v2.5.4/layui/css/modules/layer/default/layer.css" rel="stylesheet" type="text/css" />
    <link href="~/layui-v2.5.4/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <script src="~/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="~/Scripts/jquery.cookie.js"></script>
    <script src="~/Scripts/shopFrame.js" type="text/javascript"></script>
    <script src="~/Scripts/Sellerber.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery.dataTables.min.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery.dataTables.bootstrap.js" type="text/javascript"></script>
    @*<script src="~/layui-v2.5.4/layui/lay/modules/layer.js" type="text/javascript"></script>*@
    <script type="text/javascript" src="~/Scripts/proTree.js"></script>
    <script type="text/javascript" src="~/layui-v2.5.4/layui/layui.js"></script>
    <script src="~/Scripts/jquery.nicescroll.js" type="text/javascript"></script>
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js" type="text/javascript"></script>
    <script src="js/respond.min.js"></script>
    <script src="js/css3-mediaqueries.js"  type="text/javascript"></script>
      <![endif]-->
    <title>旅游图片管理</title>
</head>
<body>
    <div class="margin" id="page_style">
        @*<div class="operation clearfix mb15 same_module">
            <ul class="choice_search">
                <li class="clearfix col-xs-3 col-lg-3 col-ms-3 "><label class="label_name ">产品名称：</label><input name="" type="text" class="form-control col-xs-8 col-lg-8 col-ms-8" /></li>
                <li class="clearfix col-xs-5 col-lg-5 col-ms-5 ">
                    <label class="label_name ">添加时间：</label>
                    <input class="laydate-icon col-xs-4 col-lg-3 form-control Select_Date" id="start" />
                    <span style=" float:left; padding:0px 10px; line-height:32px;">至</span>
                    <input class="laydate-icon col-xs-4 col-lg-3 form-control Select_Date" id="end" />
                    <button class="btn button_btn bg-deep-blue " onclick="" type="button"><i class="fa  fa-search"></i>&nbsp;搜索</button>
                </li>
            </ul>
        </div>*@
        <!--列表展示-->
        <div class="h_products_list clearfix" id="Sellerber">
            <div class="Sellerber_left menu" id="menuBar">
                <div class="show_btn" id="rightArrow"><span></span></div>
                <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                <div class="menu_style" id="menu_style">
                    <div class="list_content">
                        <div class="side_list">
                            <div class="column_title"><h4 class="lighter smaller">旅游图片管理</h4></div>
                            <div class="st_tree_style tree">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="list_Exhibition list_show padding15">
                <div class="operation clearfix mb15 searchs_style">
                    <span class="submenu">
                        <a href="/Home/Add_ScenicPic" name="" class="btn button_btn bg-deep-blue" title="添加图片"><i class="fa  fa-edit"></i>&nbsp;添加图片</a>
                    </span>
                    <div class="search  clearfix">
                        <label class="label_name">图片搜索：</label><input name="" type="text" class="form-control col-xs-5" /><button class="btn button_btn bg-deep-blue " onclick="" type="button"><i class="fa  fa-search"></i>&nbsp;搜索</button>
                    </div>
                </div>
                <div class="datalist_show">
                    <div class="datatable_height confirm">
                        <table class="layui-hide" id="test" lay-filter="demo"></table>
                        <script type="text/html" id="barDemo">
                            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                        </script>
                        <script type="text/html" id="switchConnection">
                            <input type="checkbox" id="{{d.Pic_Id}}" name="State" value="{{d.Is_Master}}" lay-skin="switch" lay-text="是|否" lay-filter="sexDemo2" {{ d.Is_Master == 1 ? 'checked' : '' }}={{ d.Is_Master == 1 ? 'checked' : '' }} />

                        </script>
                        <script type="text/html" id="switchNewWindows">
                            <input type="checkbox" id="{{d.Pic_Id}}" name="State" value="{{d.Pic_Status}}" lay-skin="switch" lay-text="是|否" lay-filter="sexDemo3" {{ d.Pic_Status == 1 ? 'checked' : '' }}={{ d.Pic_Status == 1 ? 'checked' : '' }} />

                        </script>
                        <script type="text/html" id="imgUrl">
                            <img src="{{d.Pic_Url}}" style="" />
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="~/Scripts/Format.js" type="text/javascript"></script>
<script type="text/javascript">
     //layui数据表格
    layui.use('table', function () {
        var table = layui.table
        ,form = layui.form;
        table.render({
            elem: '#test'
            , url: '/Scenicpic/GetPicture'
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , cols: [[
                 { field: 'Pic_Id', width: 70, title: '图片编号'}
                , { field: 'Scenic_Id', width: 120, title: '景点Id' }
                , { field: 'Pic_Desc', width: 140, title: '图片描述' }
                , { field: 'ParentId', width: 140, title: '父级Id'}
                , { field: 'Pic_Url', width: 200, title: '缩略图', height: 500, templet: '#imgUrl' }
                , { field: 'Pic_Order', width: 140, title: '图片排序', sort: true }
                , { field: 'Is_Master', title: '是否主图', width: 150, align: 'center', templet: '#switchConnection', unresize: true }
                , { field: 'Pic_Status', title: '是否有效', width: 120, align: 'center', templet: '#switchNewWindows', unresize: true }
                , { field: 'ModifiedTime', title: '最后修改时间', width: 150, templet: "<div>{{Format(d.ModifiedTime,'yyyy-MM-dd hh:mm:ss')}}</div>", sort: true }
                , { fixed: 'right', title: '操作', width: 235, align: 'center', toolbar: '#barDemo' }
            ]]
            , page: true
            , id: 'testReload'
        });

         //是否主图切换
        form.on('switch(sexDemo2)', function (obj) {
                var id = this.id;
                var states = this.value;
                var tip = "设置为主图";
                if (this.value === "1") {
                    tip = "取消设置主图";
                    states = 0;
                }
                else {
                    states = 1;
                }
                //启用的功能代码
                layer.confirm('真的要' + tip + '吗', function (index) {
                    $.ajax({
                        url: "/Scenicpic/UpdateMaster?id=" + id + "&states=" + states,
                        type: "Post",
                        success: function (data) {
                            if (data.Success) {
                                layer.msg(tip + '成功！', {
                                    title: '提示框',
                                    icon: 1,
                                    time: 2000
                                }, function () {
                                    window.location.reload();
                                    layer.close(index);
                                });
                            }
                            else {
                                layer.msg(tip + '失败！', {
                                    title: '提示框',
                                    icon: 1,
                                    time: 2000
                                });
                            }
                        }
                    });
                });
            });


            //是否有效状态切换
            form.on('switch(sexDemo3)', function (obj) {
                var tip = "启用";
                var id = this.id;
                var states = this.value;
                if (this.value == "1") {
                    tip = "关闭";
                    states = 0;
                }
                else {
                    states = 1;
                }
                //启用的功能代码
                layer.confirm('真的要' + tip + '吗', function (index) {
                    $.ajax({
                        url: "/Scenicpic/UpdatePicState?id=" + id + "&states=" + states,
                        type: "Post",
                        success: function (data) {
                            if (data.Success) {
                                layer.msg(tip + '成功！', {
                                    title: '提示框',
                                    icon: 1,
                                    time: 2000
                                }, function () {
                                     window.location.reload();
                                    layer.close(index);
                                });
                            }
                            else {
                                layer.msg(tip + '失败！', {
                                    title: '提示框',
                                    icon: 1,
                                    time: 2000
                                });
                            }
                        }
                    });
                });
            });

        //监听工具条
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            var id = data.Pic_Id;
            if (obj.event === 'del') {
                layer.confirm('确认删除', function (index) {
                    $.ajax({
                        url: "/Scenicpic/DeletePicture",
                        type: "post",
                        data:data,
                        success: function (result) {
                            if (result.Success) {
                                layer.msg('删除成功', {
                                    title: '提示框',
                                    icon: 0,
                                    time: 2000
                                }, function () {
                                   window.location.reload(true);
                                });
                                layer.close(index);
                            }
                            else {
                                layer.msg('删除有误', {
                                    title: '提示框',
                                    icon: 0,
                                    time: 1000
                                });
                            }
                        }
                    });
                });
            } else if (obj.event === 'edit') {
                window.location.href = "/Home/Edit_ScenicPic?id=" + id;
            }
        });
        //列表刷新
        function TableReload(id) {
            var table = layui.table;
            //获取页面管理员名称和时间
            var username = $("#username").val();
            var adddate = $("#start").val();
            //上述方法等价于
            table.reload('testReload', {
                where: { //设定异步数据接口的额外参数，任意设
                    username: username,
                    adddate: adddate,
                    Id: id
                }
            });
        }

        //查询按钮点击事件
        $("#search").click(function () {
            TableReload(null);
        });
    });
    jQuery(function ($) {
        var oTable1 = $('#sample-table').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                { "orderable": false, "aTargets": [0, 2, 3, 6] }// 制定列不参与排序
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });
    });



    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $(obj).parents("tr").remove();
            layer.msg('已删除!', { icon: 1, time: 1000 });
        });
    }
    //积分浏览
    function integration_history(id) {
        layer.open({
            type: 1,
            title: '积分获取记录',
            area: ['800px', '400px'],
            shadeClose: true,
            content: $('#integration_history'),
        })
        $('#integration_history_list').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [{
                "bSortable": false,
                "orderable": false,
                "aTargets": [0, 1]
            }]
        });

    };
    //浏览记录

    function Browse_history(id) {
        layer.open({
            type: 1,
            title: '浏览记录',
            area: ['800px', '400px'],
            shadeClose: true,
            content: $('#Browse_history'),
        })
        $('#Browse_history_list').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [{
                "bSortable": false,
                "orderable": false,
                "aTargets": [0, 1]
            }]
        });
    }


    //购物记录
    function Order_history(id) {
        layer.open({
            type: 1,
            title: '购物记录',
            area: ['800px', '400px'],
            shadeClose: true,
            content: $('#Order_history'),
        });
        $('#Order_history_list').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [{
                "bSortable": false,
                "orderable": false,
                "aTargets": [0, 1]
            }]
        });
    }


</script>
